package cn.chinaunicom.sdsi.upfc_demp.hyNum.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;

import cn.chinaunicom.sdsi.frm.base.BaseService;
import cn.chinaunicom.sdsi.frm.sys.R;
import cn.chinaunicom.sdsi.frm.sys.entity.SysStaff;
import cn.chinaunicom.sdsi.frm.sys.entity.SysStaffOrg;
import cn.chinaunicom.sdsi.upfc_demp.dzgh.dao.mybatis.DzghApplyMapper;
import cn.chinaunicom.sdsi.upfc_demp.dzgh.entity.DzghApplyEntity;
import cn.chinaunicom.sdsi.upfc_demp.dzgh.service.DzghApplyService;
import cn.chinaunicom.sdsi.upfc_demp.hyNum.dao.mybatis.HyNumMapper;
import cn.chinaunicom.sdsi.upfc_demp.hyNum.entity.HyNum;
import cn.chinaunicom.sdsi.upfc_demp.hyNum.service.HyNumService;
import cn.chinaunicom.sdsi.upfc_demp.jyxx.entity.JyXx;
import cn.chinaunicom.sdsi.upfc_demp.sys.entity.SysDemo;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service
public class HyNumServiceImpl extends BaseService implements HyNumService {
    @Autowired
    private HyNumMapper hyNumMapper;

    
    /*根据主键查询核验号码信息
     * auth：jingrongze
     * 
    */
    @Override
    public HyNum selectByPrimaryKey(HyNum hyNum) {
        HyNum bean = hyNumMapper.selectByPrimaryKey(hyNum);
        return bean;
    }


    @Override
    public JSONObject searchData4Page(HyNum hyNum, Integer start, Integer pageSize) {
        //setPageInfo方法 和 mapper的查询方法必须相邻，中间不能有其他查询语句，否则mybatis的分页机制会不生效
        setPageInfo(start,pageSize);
        List<HyNum> sdsList = hyNumMapper.search4Page(hyNum);
        PageInfo page = new PageInfo(sdsList);
        JSONObject obj = null;
        JSONArray array = new JSONArray();
        for(HyNum sd :sdsList){
            obj = new JSONObject();
            obj.put("num",sd.getNum());
            array.add(obj);
        }
        obj = new JSONObject();
        obj.element("data", array);
        obj.element("recordsTotal", page.getTotal());
        obj.element("recordsFiltered", page.getTotal());
        obj.element("draw", 0);
        return obj;


    }


    @Override
    public JSONObject search4Num(HyNum bean, Integer start, Integer pageSize) {
        setPageInfo(start,pageSize);
        List<HyNum> sdsList = hyNumMapper.search4Num(bean);
        PageInfo page = new PageInfo(sdsList);
        JSONObject obj = null;
        JSONArray array = new JSONArray();
        for(HyNum sd :sdsList){
            obj = new JSONObject();
            obj.put("num",sd.getNum());
            array.add(obj);
        }
        obj = new JSONObject();
        obj.element("data", array);
        obj.element("recordsTotal", page.getTotal());
        obj.element("recordsFiltered", page.getTotal());
        obj.element("draw", 0);
        return obj;
    }

}
